package com.yuqingxin.redisCacheApi.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

import javax.annotation.Nonnull;


/**
 * @author yuqingxin
 * */
@Configuration
public class ApplicationClosedListenerConfig implements ApplicationListener<ContextClosedEvent> {

    @Autowired
    private ThreadPoolTaskScheduler threadPoolTaskScheduler;

    @Override
    public void onApplicationEvent(@Nonnull ContextClosedEvent contextClosedEvent) {
        threadPoolTaskScheduler.shutdown();
    }
}
